package com.woniu.config;


import org.springframework.amqp.core.*;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

@Configuration
public class RabbitConfig {

    @Bean(name = "topic_exchange")
    public Exchange getExchange(){
        return ExchangeBuilder.topicExchange("topic_exchange").durable(true).build();
    }

    @Bean(name = "topic_queue")
    public Queue getQueue(){
        return QueueBuilder.durable("topic_queue").build();
    }

    @Bean(name = "binding")
    public Binding getBinding(@Qualifier("topic_queue") Queue queue,@Qualifier("topic_exchange") Exchange exchange){
        return BindingBuilder.bind(queue).to(exchange).with("order.#").noargs();
    }


}
